﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;

void test() {
	int a = 10;
	const int b = a; // 如果用其他变量给const变量赋值，编译器不会优化 
	int *p = (int*)&b;
	*p = 100;
	cout << "b=" << b << endl; // 100 
	cout << "*p=" << *p << endl; // 100 
}

struct Maker {
	Maker() {
		a = 100;
	}
	int a;
};

void test02() {
	const Maker ma;
	cout << ma.a << endl;
	// ma.a = 200; // 不可修改
	Maker * p = (Maker*)&ma;
	p->a = 200;
	cout << "ma.a=" << ma.a << endl; // 自定义数据类型没有优化 

}

int main()
{
	test(); 
	test02();

	system("pause");
	return EXIT_SUCCESS;
}